Repository navigation
DEV-1291: take an in-stream ACK that comes with no data packet before it (#133, to master) - #140
Merged
Merged
Conversation
After STOP_LOGGING_ONLY_COMMAND the unit stops sending data packets for about 100 ms while it closes its SD file. A command sent in that pause is answered at once, so its ACK comes straight after the previous ACK, with no data packet before it. processPacket() only looks for an ACK after a data packet, so it threw the reply away a byte at a time. A queued command then timed out, and while streaming the timeout clears every queued instruction. The Java HIL found it on a Shimmer3 and a Shimmer3R (DEV-1269). This ports the driver's DEV-1291 fix. Shimmer overrides the streaming parser, so the driver's fix doesn't reach it. processWhileStreaming() now looks for an ACK at the start of the buffer first. It takes one only while a reply is due, and only when the bytes after it are that reply: - an in-stream reply (FF 8A, then the response opcode) to the queued GET command in flight, or to a read that readBattery() or readStatusLogAndStream() wrote straight to the socket. Those two are not queued, so Shimmer now keeps the response opcodes they await; - for the queued SET command in flight, a bare ACK whose link CRC checks out. So a 0xFF data byte the parser resyncs onto is not taken for one. An in-stream reply is parsed whole from the buffer by DEV-1149's parser, which now takes the ACK's position. Unlike the driver, Shimmer can send a read in the pause without a link CRC, because it doesn't queue the read. The ACK before the reply is then followed by another ACK rather than a packet, which processPacket() took for a parse error. It now treats it as the next frame. AAPI_00005 replays a logging stop, then a status reply, a battery reply, a queued GET's reply or a queued SET's bare ACK in the pause, in each link CRC mode that can send it and in reads of every size. Without the fix, all four fail. A fifth checks that a reply that is not due is not taken. Stacked on DEV-1149 (#122), whose in-stream parser this builds on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h no link CRC The Android HIL found it on a Shimmer3 with the link CRC off. readBattery() and readStatusLogAndStream() write their reads straight to the socket, so a queued command's ACK can come straight after a read's reply, with no data packet between them. With a link CRC on, the ACK's own CRC shows what it is, and processAckAtStartOfBuffer() already took it. With none, it threw the ACK away; STOP_LOGGING_ONLY_COMMAND then timed out, and the timeout cleared the instruction queue. Without a CRC, a bare ACK at the start of the buffer is now taken only for the queued SET command in flight. The bytes after it must also be a data packet and the start of the next frame, the same check processPacket() makes of a packet. processWhileStreaming() no longer logs "Leaving while loop" on every pass while it waits for the rest of such an ACK's frame. AAPI_00005 adds the case in every link CRC mode; without this change it fails with the CRC off. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The same two commits as #133, this time to master. #133 merged into its base, #122's branch
DEV-1149_instream_response_while_streaming, 51 s after #122 itself had merged to master. So the DEV-1291 port never reached master. This PR's diff against master is exactly #133's two commits; #122's commit is already there.What it does (from #133)
Ports the driver's DEV-1291 fix to Android's own Classic streaming parser,
Shimmer.processWhileStreaming():STOP_LOGGING_ONLY_COMMAND, is taken instead of thrown away a byte at a time;AAPI_00005_StreamingAckAfterPauseTestcovers both cases, in every CRC mode.Verified (on #133, 24 Oct)
s3-be69 (Shimmer3, LogAndStream v1.1.7) over Classic, from an M2101K6G phone on Android 11, driver 0.11.11_beta, 1-byte CRC.
inStreamMaster now has #122, so this is the build that was tested.
🤖 Generated with Claude Code